package com.ksyun.alert.utils;

import org.springframework.stereotype.Component;

/**
 * RequestIp工具类
 * @author: hantou
 * @date: 2024-05-02
 */
@Component
public class RequestIpUtil {

    private static final ThreadLocal<String> requestIpHolder = new ThreadLocal<>();

    /**
     * 设置requestIp
     * @param requestIp
     */
    public static void setRequestId(String requestIp) {
        requestIpHolder.set(requestIp);
    }


    /**
     * 获取RequestIp
     * @return RequestIp
     */
    public static String getRequestIp() {
        return requestIpHolder.get();
    }

    /**
     * 移除RequestIp
     */
    public static void removeRequestIp() {
        requestIpHolder.remove();
    }
}